package f.admin.user.servelt;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import f.tools.PropertyReader;

@WebServlet(name = "AdminUserServlet", urlPatterns = "/adminUser")
public class AdminUserServlet extends HttpServlet {

	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String account = req.getParameter("account");
		String pwd = req.getParameter("pwd");
		if(account.equals(PropertyReader.getProperty("admin.properties", "account")) && pwd.equals(PropertyReader.getProperty("admin.properties", "pwd"))) {
			req.getSession().setAttribute("loginStatus", 1);
			resp.getWriter().write("success");
		} else {
			req.getSession().setAttribute("loginStatus", 0);
			resp.getWriter().write("failure");
		}
	}
}
